package com.jy.adscm.operation.mscyb.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.jy.adscm.bean.system.JyUser;
import com.jy.adscm.operation.mscyb.bean.JqdbSettingProecss;
import com.jy.adscm.operation.mscyb.bean.JqdbSettingProecss;
import com.jy.adscm.operation.mscyb.mapper.mysql.JqdbSettingProecssMapper;
import com.jy.adscm.operation.mscyb.service.JqdbSettingProecssService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.jy.adscm.system.mapper.mysql.JyUserMapper;
import com.jy.adscm.utils.AdscmBaseUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zyl
 * @since 2019-06-17
 */
@Service
public class JqdbSettingProecssServiceImpl extends ServiceImpl<JqdbSettingProecssMapper, JqdbSettingProecss> implements JqdbSettingProecssService {
    @Autowired
    JyUserMapper jyUserMapper;
    @Override
    public List<JqdbSettingProecss> selectByPid(String pid) {
        Wrapper<JqdbSettingProecss> wrapper =new EntityWrapper<>();
        wrapper.eq("pid",pid);
        wrapper.orderBy("rank",false);
        List<JqdbSettingProecss> jqcsSettingProcesses = super.selectList(wrapper);
        for (JqdbSettingProecss jqcsSettingProcess : jqcsSettingProcesses) {
            if(AdscmBaseUtils.getInstance().isNotEmpty(jqcsSettingProcess.getCreator(),null)){
                JyUser jyUser = jyUserMapper.selectById(jqcsSettingProcess.getCreator());
                jqcsSettingProcess.setCreatorName(jyUser.getName());
            }

        }
        return jqcsSettingProcesses;
    }
}
